﻿using Microsoft.EntityFrameworkCore;


namespace ModelMigration
{
    public class MyModel
    {
        public int Id { get; set; }
        public string? Text { get; set; }
    }

    public class ModelDbContext : DbContext
    {
        public DbSet<MyModel> MyModels { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
            optionsBuilder.UseSqlServer(
          "Server=(localdb)\\mssqllocaldb;Database=MigrationTest;Trusted_Connection=True;MultipleActiveResultSets=true"/*,
            // 手动配置迁移程序集
            options =>
            {
                options.MigrationsAssembly("迁移程序集名称");
            }*/);

            // 替换Sql生成器
            //optionsBuilder.ReplaceService<IMigrationsSqlGenerator, MySqlServerMigrationsSqlGenerator>();
            // 替换迁移历史记录管理器
            //optionsBuilder.ReplaceService<IHistoryRepository, MySqlServerHistoryRepository>();
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

        }

    }
}
